import 'package:flutter/material.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Padding示例',
      theme: ThemeData(primarySwatch: Colors.blue),
      home: const PaddingTestRoute(),
    );
  }
}

class PaddingTestRoute extends StatelessWidget {
  const PaddingTestRoute({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Padding(
      //上下左右各添加16像素补白，所有方向相同边距
      padding: const EdgeInsets.all(16),
      child: Column(
        //显式指定对齐方式为左对齐，排除对齐干扰
        crossAxisAlignment: CrossAxisAlignment.start,
        mainAxisSize: MainAxisSize.min,
        children: const <Widget>[
          Padding(
            //左边添加8像素补白，指定方向
            padding: EdgeInsets.only(left: 8),
            child: Text(
              "Hello world",
              style: TextStyle(color: Colors.black, fontSize: 12),
            ),
          ),
          Padding(
            //上下各添加8像素补白，对称边距
            padding: EdgeInsets.symmetric(vertical: 30),
            child: Text(
              "I am Jack",
              style: TextStyle(color: Colors.black, fontSize: 12),
            ),
          ),
          Padding(
            // 分别指定四个方向的补白（左，上，右，下）
            padding: EdgeInsets.fromLTRB(20, 0, 20, 20),
            child: Text(
              "Your friend",
              style: TextStyle(color: Colors.black, fontSize: 12),
            ),
          ),
        ],
      ),
    );
  }
}
